<template>
  <div class="Echarts" style="height:750px" >
    <div id="main" style="width: 600px;height:400px; margin:auto"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  mounted() {
    this.datas();
  },

  methods: {
    datas() {
      this.$axios({
        method: "get",
        url: "/nces/ncesUser",
      })
        .then((res) => {
          res;
          console.log(res);
          var datas = new Array();
          datas.push(res.data.result.Allcustomers);
          datas.push(res.data.result.Allworkers);
          datas.push(res.data.result.Allusers);
          datas.push(res.data.result.DispatchWorkers);
          console.log(datas);
          var myChart = this.$echarts.init(document.getElementById("main"));
          var option = {
            title: {
              text: "用户统计",
            },
            tooltip: {},
            legend: {
              data: ["用户数量"],
            },
            xAxis: {
              data: ["所有客户", "所有工人", "所有用户", "派出的工人"],
            },
            yAxis: {},
            series: [
              {
                name: "用户数量",
                type: "bar",
                data:datas,
              },
            ],
          };
          myChart.setOption(option);
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
};
</script>

<style></style>
